package 传智播客_黑马.java高级.函数式.练习;

import java.util.function.Supplier;

public class 获取最大值 {
    public static int getMax(Supplier<Integer> sup){
        return sup.get();
    }


    public static void main(String[] args) {
        int[] nums = new int[]{1,2,3,4,5,9,8,7,6,0};

        getMax(()->{
            int max = nums[0];
            for (int num : nums) {
//                max = num>max?num:max;
                max = Math.max(num, max);
            }
            System.out.println("max = " + max);
            return max;
        });
    }
}
